.global _loader					# making entry point visible to linker

# setting up the Multiboot header - see GRUB docs for details
.set ALIGN,    1<<0				# align loaded modules on page boundaries
.set MEMINFO,  1<<1				# provide memory map
.set FLAGS,    ALIGN | MEMINFO	# this is the Multiboot 'flag' field
.set MAGIC,    0x1BADB002		# 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS)	# checksum required

# --kmcguire:
# By putting the multi-boot header in it's own section it and altering linker.ld it seems to help ensure it is always with in
# the maximum search distance for GRUB when looking for the MAGIC value.
.align 4
.section .multiboot
.long MAGIC
.long FLAGS
.long CHECKSUM

# --kmcguire: (return to the .text section)
.text

# reserve initial kernel stack space
.set STACKSIZE, 0x4000			# that is, 16k.
.comm stack, STACKSIZE, 32		# reserve 16k stack on a quadword boundary

_loader:
	mov  $(stack + STACKSIZE), %esp	# set up the stack
	push %ebx					# Multiboot data structure

	cli
	call main					# call kernel proper